load("@fbcode_macros//build_defs/lib:rust_oss.bzl", "rust_oss")
load("@fbsource//tools/build_defs:rust_library.bzl", "rust_library")

oncall("scm_server_infra")

rust_library(
    name = "pushrebase",
    srcs = glob(["src/**/*.rs"]),
    test_deps = [
        "fbcode//eden/mononoke/blobrepo:blobrepo_hg",
        "fbsource//third-party/rust:async-trait",
        "fbsource//third-party/rust:rand",
        "fbsource//third-party/rust:tokio",
        "//common/rust/shed/cloned:cloned",
        "//common/rust/shed/facet:facet",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/fbinit:fbinit-tokio",
        "//eden/mononoke/common/rust/sql_ext:sql_ext",
        "//eden/mononoke/filestore:filestore",
        "//eden/mononoke/manifest:manifest",
        "//eden/mononoke/mononoke_macros:mononoke_macros",
        "//eden/mononoke/mutable_counters:mutable_counters",
        "//eden/mononoke/repo_factory:test_repo_factory",
        "//eden/mononoke/tests/fixtures:fixtures",
        "//eden/mononoke/tests/utils:tests_utils",
    ],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:maplit",
        "fbsource//third-party/rust:thiserror",
        "fbsource//third-party/rust:tracing",
        ":pushrebase_hook",
        "//common/rust/shed/stats:stats",
        "//eden/mononoke/blobrepo_utils:blobrepo_utils",
        "//eden/mononoke/blobstore:blobstore",
        "//eden/mononoke/bonsai_hg_mapping:bonsai_hg_mapping",
        "//eden/mononoke/bookmarks:bookmarks",
        "//eden/mononoke/changesets/changesets_creation:changesets_creation",
        "//eden/mononoke/derived_data/filenodes_derivation:filenodes_derivation",
        "//eden/mononoke/derived_data/mercurial_derivation:mercurial_derivation",
        "//eden/mononoke/manifest:manifest",
        "//eden/mononoke/mercurial:mercurial_types",
        "//eden/mononoke/metaconfig:metaconfig_types",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/repo_attributes/commit_graph/commit_graph:commit_graph",
        "//eden/mononoke/repo_attributes/repo_blobstore:repo_blobstore",
        "//eden/mononoke/repo_attributes/repo_derived_data:repo_derived_data",
        "//eden/mononoke/repo_attributes/repo_identity:repo_identity",
        "//eden/mononoke/server/context:context",
    ],
)

rust_library(
    name = "pushrebase_hook",
    srcs = glob(["pushrebase_hook/**/*.rs"]),
    autocargo = {"cargo_toml_dir": "pushrebase_hook"},
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:async-trait",
        "//eden/mononoke/bookmarks:bookmarks",
        "//eden/mononoke/common/rust/sql_ext:sql_ext",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/server/context:context",
    ],
)

rust_library(
    name = "pushrebase_hooks",
    srcs = glob(["pushrebase_hooks/**/*.rs"]),
    autocargo = {"cargo_toml_dir": "pushrebase_hooks"},
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:thiserror",
        "//eden/mononoke/bonsai_git_mapping:bonsai_git_mapping",
        "//eden/mononoke/bonsai_git_mapping:git_mapping_pushrebase_hook",
        "//eden/mononoke/bonsai_globalrev_mapping:bonsai_globalrev_mapping",
        "//eden/mononoke/bonsai_globalrev_mapping:globalrev_pushrebase_hook",
        "//eden/mononoke/bookmarks:bookmarks_types",
        "//eden/mononoke/commit_rewriting/synced_commit_mapping:synced_commit_mapping_pushrebase_hook",
        "//eden/mononoke/metaconfig:metaconfig_types",
        "//eden/mononoke/pushrebase:pushrebase_hook",
        "//eden/mononoke/pushrebase_mutation_mapping:pushrebase_mutation_mapping",
        "//eden/mononoke/repo_attributes/repo_bookmark_attrs:repo_bookmark_attrs",
        "//eden/mononoke/repo_attributes/repo_cross_repo:repo_cross_repo",
        "//eden/mononoke/repo_attributes/repo_identity:repo_identity",
        "//eden/mononoke/server/context:context",
    ],
)

rust_library(
    name = "pushrebase_client",
    srcs = glob(["client/**/*.rs"]),
    autocargo = {"cargo_toml_dir": "client"},
    deps = ([
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:async-trait",
        "fbsource//third-party/rust:bytes",
        "//eden/mononoke/bookmarks:bookmarks",
        "//eden/mononoke/bookmarks:bookmarks_movement",
        "//eden/mononoke/bookmarks:bookmarks_types",
        "//eden/mononoke/common/facebook/thrift_client:thrift_client",
        "//eden/mononoke/common/scuba_ext:scuba_ext",
        "//eden/mononoke/hooks:hooks",
        "//eden/mononoke/metaconfig:metaconfig_types",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/pushrebase:pushrebase",
        "//eden/mononoke/repo_authorization:repo_authorization",
        "//eden/mononoke/server/context:context",
    ] + ([] if rust_oss.is_oss_build() else [
        "fbsource//third-party/rust:arc-swap",
        "//eden/mononoke/land_service/if:land_service_if-rust",
        "//eden/mononoke/land_service/if:land_service_if-rust-clients",
        "//eden/mononoke/repo_attributes/repo_identity:repo_identity",
        "//eden/mononoke/common/facebook/db_primary_region:db_primary_region",
    ])),
)
